#include "StdAfx.h"
#include "CircuitPieChart.h"


CCircuitPieChart::CCircuitPieChart(void)
{
	m_dblPosX = 0.0;
	m_dblPosY = 0.0;
	m_dblRadius = 0.0;
	m_borderWidth = 0.0;
	m_dblStartAngle = 0.0;
	m_dblEndAngle = 0.0;
	m_dblBorderColor[0] = 0.0;
	m_dblBorderColor[1] = 0.0;
	m_dblBorderColor[2] = 0.0;
	m_dblFillColor[0] = 0.0;
	m_dblFillColor[1] = 0.0;
	m_dblFillColor[2] = 0.0;
	m_bIsFill = false;
	m_bSelected = false;
}

CCircuitPieChart::CCircuitPieChart(const CCircuitPieChart *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblPosX = pEntityObj->GetPosX();
	m_dblPosY = pEntityObj->GetPosY();
	m_dblRadius = pEntityObj->GetRadius();
	m_borderWidth = pEntityObj->GetBorderWidth();
	m_dblStartAngle = pEntityObj->GetStartAngle();
	m_dblEndAngle = pEntityObj->GetEndAngle();
	m_dblBorderColor[0] = pEntityObj->GetBorderColorR();
	m_dblBorderColor[1] = pEntityObj->GetBorderColorG();
	m_dblBorderColor[2] = pEntityObj->GetBorderColorB();
	m_dblFillColor[0] = pEntityObj->GetFillColorR();
	m_dblFillColor[1] = pEntityObj->GetFillColorG();
	m_dblFillColor[2] = pEntityObj->GetFillColorB();
	m_bIsFill = pEntityObj->IsFill();
	m_bSelected = pEntityObj->IsSelect();
}

CCircuitPieChart::CCircuitPieChart(CICircuit *pParentEnt)
	:CCircuitUnit(pParentEnt)
{
	m_dblPosX = 0.0;
	m_dblPosY = 0.0;
	m_dblRadius = 0.0;
	m_borderWidth = 0.0;
	m_dblStartAngle = 0.0;
	m_dblEndAngle = 0.0;
	m_dblBorderColor[0] = 0.0;
	m_dblBorderColor[1] = 0.0;
	m_dblBorderColor[2] = 0.0;
	m_dblFillColor[0] = 0.0;
	m_dblFillColor[1] = 0.0;
	m_dblFillColor[2] = 0.0;
	m_bIsFill = false;
	m_bSelected = false;
}

CCircuitPieChart::~CCircuitPieChart(void)
{
}

void CCircuitPieChart::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblPosX;
		ar << m_dblPosY;
		ar << m_dblRadius;
		ar << m_borderWidth;
		ar << m_dblStartAngle;
		ar << m_dblEndAngle;
		ar << m_dblBorderColor[0];
		ar << m_dblBorderColor[1];
		ar << m_dblBorderColor[2];
		ar << m_bIsFill;
		ar << m_dblFillColor[0];
		ar << m_dblFillColor[1];
		ar << m_dblFillColor[2];
		ar << m_bSelected;
	}
	else
	{
		if(CObj::m_lFileVersion >= 95)
		{
			ar >> m_dblPosX;
			ar >> m_dblPosY;
			ar >> m_dblRadius;
			ar >> m_borderWidth;
			ar >> m_dblStartAngle;
			ar >> m_dblEndAngle;
			ar >> m_dblBorderColor[0];
			ar >> m_dblBorderColor[1];
			ar >> m_dblBorderColor[2];
			ar >> m_bIsFill;
			ar >> m_dblFillColor[0];
			ar >> m_dblFillColor[1];
			ar >> m_dblFillColor[2];
			ar >> m_bSelected;
		}
	}

	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitPieChart::Clone() const
{
	return new CCircuitPieChart(this);
}

void CCircuitPieChart::Transform(const CMatrix transf)
{

}

bool CCircuitPieChart::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitPieChart::Clear()
{

}

void CCircuitPieChart::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitPieChart::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitPieChart::CreateDisplayObj(long lLayerId)
{
	CCircuitPieChartDisObj *pPieDis = new CCircuitPieChartDisObj(this);
	pPieDis->SetLayerId(lLayerId);
	return pPieDis;
}

void CCircuitPieChart::CalcBox()
{
	m_minX = m_dblPosX-m_dblRadius;
	m_minY = m_dblPosY-m_dblRadius;
	m_maxX = m_dblPosX+m_dblRadius;
	m_maxY = m_dblPosY+m_dblRadius;
}

eCircuitUnitEntType CCircuitPieChart::GetUnitType() const
{
	return CIRCUIT_PIECHART;
}

double CCircuitPieChart::GetPosX() const
{
	return m_dblPosX ;
}

double CCircuitPieChart::GetPosY() const
{
	return m_dblPosY;
}

double CCircuitPieChart::GetRadius() const
{
	return m_dblRadius;
}

double CCircuitPieChart::GetBorderWidth() const
{
	return m_borderWidth;
}

double CCircuitPieChart::GetBorderColorR() const
{
	return m_dblBorderColor[0];
}

double CCircuitPieChart::GetBorderColorG() const
{
	return m_dblBorderColor[1];
}

double CCircuitPieChart::GetBorderColorB() const
{
	return m_dblBorderColor[2];
}

double CCircuitPieChart::GetStartAngle() const
{
	return m_dblStartAngle;
}

double CCircuitPieChart::GetEndAngle() const
{
	return m_dblEndAngle;
}

bool CCircuitPieChart::IsSelect() const
{
	return m_bSelected;
}

bool CCircuitPieChart::IsFill() const
{
	return m_bIsFill;
}

double CCircuitPieChart::GetFillColorR() const
{
	return m_dblFillColor[0];
}

double CCircuitPieChart::GetFillColorG() const
{
	return m_dblFillColor[1];
}

double CCircuitPieChart::GetFillColorB() const
{
	return m_dblFillColor[2];
}

void CCircuitPieChart::SetPosX(double pos) 
{
	m_dblPosX = pos;
}
void CCircuitPieChart::SetPosY(double pos)
{
	m_dblPosY = pos;
}

void CCircuitPieChart::SetRadius(double rad)
{
	m_dblRadius = rad;
}

void CCircuitPieChart::SetBorderWidth(double dblWidth)
{
	m_borderWidth = dblWidth;
}

void CCircuitPieChart::SetBorderColorR(double colR)
{
	m_dblBorderColor[0] = colR;
}

void CCircuitPieChart::SetBorderColorG(double colG)
{
	m_dblBorderColor[1] = colG;
}

void CCircuitPieChart::SetBorderColorB(double colB)
{
	m_dblBorderColor[2] = colB;
}

void CCircuitPieChart::SetStartAngle(double angle)
{
	m_dblStartAngle = angle;
}

void CCircuitPieChart::SetEndAngle(double angle)
{
	m_dblEndAngle = angle;
}

void CCircuitPieChart::SetSelect(bool bFlag)
{
	m_bSelected = bFlag;
}

void CCircuitPieChart::SetFill(bool bFlag)
{
	m_bIsFill = bFlag;
}

void CCircuitPieChart::SetFillColorR(double colR)
{
	m_dblFillColor[0] = colR;
}

void CCircuitPieChart::SetFillColorG(double colG)
{
	m_dblFillColor[1] = colG;
}

void CCircuitPieChart::SetFillColorB(double colB)
{
	m_dblFillColor[2] = colB;
}